/*
 * @Author: cgl
 * @Date: 2023-04-12 15:25:43
 * @LastEditors: cgl
 * @LastEditTime: 2023-09-01 14:52:44
 * @FilePath: \public-health-emergencies-fed:\新放射\新radiation-hygiene-fe\src\main.js
 * @Description:
 *
 * Copyright (c) 2023 by cgl/微盛信息产业有限公司, All Rights Reserved.
 */
import Vue from 'vue'
require('promise.prototype.finally').shim();
import Cookies from 'js-cookie'

import Element from 'element-ui'
import './assets/styles/element-variables.scss'

import '@/assets/styles/index.scss' // global css
import '@/assets/styles/ruoyi.scss' // ruoyi css
import App from './App'
import store from './store'
import router from './router'
import directive from './directive' // directive
import plugins from './plugins' // plugins
import { download } from '@/utils/request'
import Big from 'big-js'

import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey, updateConfigByKey } from "@/api/system/config";
import { sleep } from '@/utils/index'
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, handleTree } from "@/utils/ruoyi";
import { copyText } from '@/utils/copy'
// 分页组件
import Pagination from "@/components/Pagination";
// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar"
// 富文本组件
import Editor from "@/components/Editor"
// 文件上传组件
import FileUpload from "@/components/FileUpload"
// 图片上传组件
import ImageUpload from "@/components/ImageUpload"
// 图片预览组件
import ImagePreview from "@/components/ImagePreview"
// 字典标签组件
import DictTag from '@/components/DictTag'
// 头部标签组件
import VueMeta from 'vue-meta'
// 字典数据组件
import DictData from '@/components/DictData'
import config from '@/utils/config';
import {validate, elHaveComponent, bind,unbind,jsonParse} from '@/views/slide/components/util'
import {resetSetItem} from "@/plugins/cache"
import print from "vue-print-nb";
import printCom from "@/components/Print"
import mySelect from '@/components/select/src/mySelect'
import OrganizationSelect from '@/components/OrganizationSelect'
import OrganizationCompleteSelect from '@/components/OrganizationCompleteSelect'
import ProjectSelect from '@/components/ProjectSelect'
import ProjectCompleteSelect from '@/components/ProjectCompleteSelect'
import UserCompleteSelect from '@/components/UserCompleteSelect'
import SelectScroll from "@/components/select/src/SelectScroll"
import userSelect from "@/components/select/src/userSelect"
import GiveBackList from "@/views/resource/giveBack"
import customComponents from "@/components/custom"
//鼠标滚动
import MouseScroll from "@/directive/mouse/mouseScroll";
import AsyncComputed from 'vue-async-computed'
import { checkPermi } from '@/utils/permission';

import VXETable from 'vxe-table'
import 'vxe-table/lib/style.css'

//loadsh组件
import lodash from 'lodash';

// 全局方法挂载
Vue.prototype.big = Big
Vue.prototype.getDicts = getDicts
Vue.prototype.sleep = sleep
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.updateConfigByKey = updateConfigByKey
Vue.prototype.parseTime = parseTime
Vue.prototype.resetForm = resetForm
Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree
Vue.prototype.validate = validate
Vue.prototype.elHaveComponent = elHaveComponent
Vue.prototype.bind = bind
Vue.prototype.unbind = unbind
Vue.prototype.resetSetItem = resetSetItem
Vue.prototype.jsonParse = jsonParse
Vue.prototype.$copyText = copyText
Vue.prototype.$bus = new Vue()
Vue.prototype.$lodash = lodash
Vue.prototype.checkPermi = checkPermi

// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('Pagination', Pagination)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)
Vue.component('FileUpload', FileUpload)
Vue.component('ImageUpload', ImageUpload)
Vue.component('ImagePreview', ImagePreview)
Vue.component('print', printCom)
Vue.component('OrganizationSelect', OrganizationSelect)
Vue.component('OrganizationCompleteSelect', OrganizationCompleteSelect)
Vue.component('ProjectSelect', ProjectSelect)
Vue.component('ProjectCompleteSelect', ProjectCompleteSelect)
Vue.component('UserCompleteSelect', UserCompleteSelect)
Vue.component('mySelect', mySelect)
Vue.component('SelectScroll', SelectScroll)
Vue.component('userSelect', userSelect)
Vue.component('GiveBackList', GiveBackList)

Vue.use(MouseScroll)
Vue.use(directive)
Vue.use(plugins)
Vue.use(VueMeta)
Vue.use(AsyncComputed)
Vue.use(VXETable)
DictData.install()
customComponents.install()

//全局注册指令
Vue.directive('print',print)
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online! ! !
 */

// 修改 el-dialog 默认点击遮照为不关闭
Element.Dialog.props.closeOnClickModal.default = false

Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})

Vue.config.productionTip = false

// 全局点击防抖处理 并去除focus
const on = Vue.prototype.$on
Vue.prototype.$on = function (e, func) {
  // 目前只有点击需要防抖
  if (e === 'click') {
    let sto
    on.call(this, e, function () {
      sto ? clearTimeout(sto) : func.apply(this, arguments)
      sto = setTimeout(() => sto = undefined, 500)
      // 点击后移除焦点
      this.$el && this.$el.blur()
    })
  } else {
    on.call(this, e, func)
  }
}

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
